package java3_28;

import java.util.*;

public class ListTimeCompare {
    public static void main(String[] args) {
        ArrayList li = new ArrayList();
        int count1 = 0;
        long start = System.nanoTime();
        for (int i = 0; i < 100000; i++) {
            count1++;
            li.add(count1);
        }
        for (int i = 0; i < 100; i++) {
            int num1 = (int)Math.random()*100000;
            li.remove(num1);
        }
        long end = System.nanoTime();
        System.out.println("ArrayList时间:"+(end-start));
        System.out.println("******************************************");

        LinkedList lk = new LinkedList();
        int count2 = 0;
        long start2 = System.nanoTime();
        for (int i = 0; i < 100000; i++) {
            count2++;
            lk.add(count2);
        }
        for (int i = 0; i < 100; i++) {
            int num2 = (int)Math.random()*100000;
            li.remove(num2);
        }
        long end2 = System.nanoTime();
        System.out.println("Linkedlist时间:"+(end2-start2));
    }
}
